/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.games.epkb.entityClasses;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author plebani
 */
@Entity
@Table(name = "process_structure")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ProcessStructure.findAll", query = "SELECT p FROM ProcessStructure p"),
    @NamedQuery(name = "ProcessStructure.findByIDActivityPREC", query = "SELECT p FROM ProcessStructure p WHERE p.processStructurePK.iDActivityPREC = :iDActivityPREC"),
    @NamedQuery(name = "ProcessStructure.findByIDActivityFOLLOW", query = "SELECT p FROM ProcessStructure p WHERE p.processStructurePK.iDActivityFOLLOW = :iDActivityFOLLOW"),
    @NamedQuery(name = "ProcessStructure.findByIdProcess", query = "SELECT p FROM ProcessStructure p WHERE p.processStructurePK.idProcess = :idProcess"),
    @NamedQuery(name = "ProcessStructure.findByIdThisActivity", query = "SELECT p FROM ProcessStructure p WHERE p.processStructurePK.idThisActivity = :idThisActivity"),
    @NamedQuery(name = "ProcessStructure.findByOptional", query = "SELECT p FROM ProcessStructure p WHERE p.optional = :optional"),
    @NamedQuery(name = "ProcessStructure.findByExecutionProbability", query = "SELECT p FROM ProcessStructure p WHERE p.executionProbability = :executionProbability")})
public class ProcessStructure implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ProcessStructurePK processStructurePK;
    @Column(name = "Optional")
    private Boolean optional;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "ExecutionProbability")
    private BigDecimal executionProbability;
    @JoinColumn(name = "Id_Process", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private BusinessProcess businessProcess;
    @JoinColumn(name = "IDActivityPREC", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Activity activity;
    @JoinColumn(name = "IDActivityFOLLOW", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Activity activity1;
    @JoinColumn(name = "Id_ThisActivity", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Activity activity2;

    public ProcessStructure() {
    }

    public ProcessStructure(ProcessStructurePK processStructurePK) {
        this.processStructurePK = processStructurePK;
    }

    public ProcessStructure(String iDActivityPREC, String iDActivityFOLLOW, String idProcess, String idThisActivity) {
        this.processStructurePK = new ProcessStructurePK(iDActivityPREC, iDActivityFOLLOW, idProcess, idThisActivity);
    }

    public ProcessStructurePK getProcessStructurePK() {
        return processStructurePK;
    }

    public void setProcessStructurePK(ProcessStructurePK processStructurePK) {
        this.processStructurePK = processStructurePK;
    }

    public Boolean getOptional() {
        return optional;
    }

    public void setOptional(Boolean optional) {
        this.optional = optional;
    }

    public BigDecimal getExecutionProbability() {
        return executionProbability;
    }

    public void setExecutionProbability(BigDecimal executionProbability) {
        this.executionProbability = executionProbability;
    }

    public BusinessProcess getBusinessProcess() {
        return businessProcess;
    }

    public void setBusinessProcess(BusinessProcess businessProcess) {
        this.businessProcess = businessProcess;
    }

    public Activity getActivity() {
        return activity;
    }

    public void setActivity(Activity activity) {
        this.activity = activity;
    }

    public Activity getActivity1() {
        return activity1;
    }

    public void setActivity1(Activity activity1) {
        this.activity1 = activity1;
    }

    public Activity getActivity2() {
        return activity2;
    }

    public void setActivity2(Activity activity2) {
        this.activity2 = activity2;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (processStructurePK != null ? processStructurePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ProcessStructure)) {
            return false;
        }
        ProcessStructure other = (ProcessStructure) object;
        if ((this.processStructurePK == null && other.processStructurePK != null) || (this.processStructurePK != null && !this.processStructurePK.equals(other.processStructurePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "it.polimi.games.epkb.entityClasses.ProcessStructure[ processStructurePK=" + processStructurePK + " ]";
    }
    
}
